#include "cnninfo.h"

CnnInfo::CnnInfo() {

}

bool CnnInfo::WriteXML(QXmlStreamWriter &writer){
    writer.writeStartElement("CnnInfo");
    writer.writeTextElement("PartWidth",QString::number(m_nPartWidth));
    writer.writeTextElement("PartHeight",QString::number(m_nPartHeight));
    //writer.writeTextElement("OnnxModelPath",m_strONNXmodelPath);
    writer.writeEndElement();
    return true;
}

bool CnnInfo::ReadXML(QXmlStreamReader &reader){
    QXmlStreamReader::TokenType token = reader.readNext();
    while (!(reader.tokenType() == QXmlStreamReader::EndElement &&
             reader.name() == QStringLiteral("CnnInfo"))) {

        if (reader.name() == QStringLiteral("PartWidth")) {
            m_nPartWidth = reader.readElementText().toInt();
        }else if (reader.name() == QStringLiteral("PartHeight")) {
            m_nPartHeight = reader.readElementText().toInt();
        }
        /*else if (reader.name() == QStringLiteral("OnnxModelPath")) {
            m_strONNXmodelPath = reader.readElementText().toStdString().c_str();
        }*/

        reader.readNext();
    }

    reader.readNext();
    reader.readNext();
    return true;
}
